A debugger is software that identifies “bugs” in a program as the program is developed. As used herein a “bug” is any behavior in a program that is not what the program is intended to do. The debugger further helps a programmer to fix program code that does not operate in a desired manner. Typically, a debugger allows the programmer to monitor the program as the program executes. The programmer may modify instructions in the program using the debugger. Furthermore, the programmer may use the debugger to modify values stored in memory for the program.
The debugger may further allow the programmer to start and stop execution of the program in multiple ways. For example, the debugger may enable the programmer to insert breakpoints in the program that halt execution of the program at the locations where the breakpoints are inserted. The debugger may further allow the programmer to view values of variables and other objects at the breakpoints. For example, the programmer can view the state of the program at each breakpoint and thus, gather valuable information regarding how the program behaves.
The debugger may further allow the programmer to start and stop program execution via a technique called “single stepping.” With single stepping, a single statement in the program is executed then program execution is halted. Then, the next statement is executed and program execution is halted. This process may repeat as long as single stepping is active or until the end of the program is reached.
Debuggers may require that the program be available in executable form for the program to be executed. In many instances, a compiler will generate this executable form of the program. The compiler builds a symbol table when compiling the program. The symbol table is a data structure that holds information regarding each identifier in the program. The information may include type, size, and memory location of each object that is identified by an identifier in the program and is specific to the programming language in which the program is written.
The debugger may access information in the symbol table to display information regarding an object in the program. For example, the debugger may display a value for an object when program execution is halted. To display the object's value, the debugger may need to locate and read the language-specific representation of the value of the object which is stored in memory, and convert the information into a representation that the debugger can understand (e.g. a “source code representation”). Based on the information in the symbol table, the debugger determines the data type (language-specific), size and memory location of the representation of the object. The debugger reads the value of the language-specific representation of the object at the memory location specified by the symbol table. The debugger uses the type definition for the type specified for the object in the symbol table to format and display the value of the object. A debugger may use its own conversion to read from the symbol table to convert the language-specific representation of the object to source code representation. The debugger then displays the source code representation of the object using a presentation layer in the debugger, where the presentation layer is a component that displays information to the user and/or that accepts information from the user.
In addition to accessing the symbol table to display a value of an object, the debugger may also access the symbol table to modify a value of an object when program execution is halted. For example, when the programmer provides a modified value of an object (such as a variable) through the presentation layer of the debugger, the debugger receives the value in a format that is native to the debugger (e.g. the source code representation). The debugger uses the information in the symbol table and the debugger's conversion function to convert the modified value in the source code representation of the object into a corresponding modified value of the language-specific representation of the object.